//
//  Menu.m
//  2017classone
//
//  Created by M on 17/3/15.
//  Copyright © 2017年 apple1512. All rights reserved.
//

#import "Menu.h"

@interface Menu () <UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Rightmargin;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Leftmargin;
@property (weak, nonatomic) IBOutlet UITableView *tableview;

@end

@implementation Menu

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tableview.backgroundColor = [UIColor orangeColor];
    self.Rightmargin.constant = self.Leftmargin.constant - self.view.bounds.size.width;
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"菜单" style:UIBarButtonItemStylePlain target:self action:@selector(onMamiu:)];
}

- (void)onMamiu:(id)sender{

    if (_Rightmargin.constant == 0){
    
        [UIView animateWithDuration:0 delay:0.5 options: UIViewAnimationOptionCurveEaseInOut                                    animations:^{
        
            self.Rightmargin.constant = self.Leftmargin.constant - self.view.bounds.size.width;
            self.Leftmargin.constant = self.view.bounds.size.width;
            [self.view layoutIfNeeded];
        } completion:nil];
    
    }else{
    
        [UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveLinear animations:^{
        
            self.Leftmargin.constant = self.Rightmargin.constant + self.view.bounds.size.width;
            self.Rightmargin.constant = 0;
            
            [self.view layoutIfNeeded];
        }completion:nil];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    cell.textLabel.text = @"1212";
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
